package com.mec.offload.service.impl;


import com.mec.offload.dao.SubTaskMapper;
import com.mec.offload.model.SubTask;
import com.mec.offload.service.SubTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubTaskServiceImpl implements SubTaskService {
    @Autowired
    SubTaskMapper subTaskMapper;
    public List<SubTask> getTaskByTaskLoc(Integer id){
        try {
            return subTaskMapper.getTaskByTaskLoc(id);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public List<SubTask>getTaskByTaskOffload(Integer id){
        try {
            return subTaskMapper.getTaskByTaskOffload(id);
        }catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public List<SubTask> getSubMission(Integer taskId){
        try {
            return subTaskMapper.getSubMission(taskId);
        }catch (Exception e)
        {
            e.printStackTrace();
            return null;
        }
    }
    public int SubTaskToMs(Integer subTaskId)
    {
        try {
            return subTaskMapper.SubTaskToMs(subTaskId);
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }
    public int SubTaskToTs(Integer subTaskId){
        try {
            return subTaskMapper.SubTaskToTs(subTaskId);
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }
    public int updateSubTask(SubTask subTask){
        try {
            return subTaskMapper.updateSubTask(subTask);
        }catch (Exception e){
            e.printStackTrace();
            return  0;
        }
    }
    public List<SubTask>getSubTaskInMsOnce(Integer taskId){
        try {
            return subTaskMapper.getSubTaskInMsOnce(taskId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public SubTask getSubTaskById(Integer subTaskId){
        try {
            return subTaskMapper.getSubTaskById(subTaskId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    public List<SubTask> queryAllDataFromTable(int page, int limit, int taskId){
        page=(page-1)*limit;
        return subTaskMapper.queryAllDataFromTable(page,limit,taskId);
    }
    public int queryziAllCount(Integer TaskId){
        return subTaskMapper.queryziAllCount(TaskId);
    }

}
